package com.example.moshudriver.protocol;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.external.activeandroid.DataBaseModel;
import com.external.activeandroid.annotation.Column;
import com.external.activeandroid.annotation.Table;

@Table(name = "orderinfoRequest")
public class orderinfoRequest extends DataBaseModel {

	@Column(name = "uid")
	public int uid;

	@Column(name = "sid")
	public String sid;

	@Column(name = "ver")
	public int ver;

	@Column(name = "order_id")
	public int order_id;

	@Column(name = "offer_distance")
	public String offer_distance;

	@Column(name = "transaction_distance")
	public String transaction_distance;

	public void fromJson(JSONObject jsonObject) throws JSONException {
		if (null == jsonObject) {
			return;
		}

		JSONArray subItemArray;

		this.uid = jsonObject.optInt("uid");

		this.sid = jsonObject.optString("sid");

		this.offer_distance = jsonObject.optString("offer_distance");

		this.transaction_distance = jsonObject
				.optString("transaction_distance");

		this.ver = jsonObject.optInt("ver");

		this.order_id = jsonObject.optInt("order_id");
		return;
	}

	public JSONObject toJson() throws JSONException {
		JSONObject localItemObject = new JSONObject();
		JSONArray itemJSONArray = new JSONArray();
		localItemObject.put("uid", uid);
		localItemObject.put("sid", sid);
		localItemObject.put("ver", ver);
		localItemObject.put("offer_distance", offer_distance);
		localItemObject.put("transaction_distance", transaction_distance);
		localItemObject.put("order_id", order_id);
		return localItemObject;
	}

}
